find longest sub string length with k distinct characters